package com.zxm.sunshineaiary.view.mydialog.basedialog;

import com.zxm.sunshineaiary.activity.R;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class BasDialog extends Dialog implements OnClickListener {

	protected Context mContext = null;
	protected TextView dialogTitle = null;
	protected Button confrimButton = null;
	protected Button cancelButton = null;

	public BasDialog(Context context) {
		super(context, R.style.dialog);
		mContext = context;
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.setContentView(R.layout.dialog);

		this.setCanceledOnTouchOutside(true);
		WindowManager.LayoutParams params = this.getWindow().getAttributes();
		params.width = WindowManager.LayoutParams.FILL_PARENT;
		params.height = WindowManager.LayoutParams.WRAP_CONTENT;
		this.getWindow().setAttributes(params);
		findView();
		setListener();
	}

	private void findView() {
		confrimButton = (Button) findViewById(R.id.dialog_confirmButton);
		cancelButton = (Button) findViewById(R.id.dialog_cancelButton);
		dialogTitle = (TextView) findViewById(R.id.dialog_textTile);
	}

	private void setListener() {
		confrimButton.setOnClickListener(this);
		cancelButton.setOnClickListener(this);
	}

	protected void setTitileText() {
		dialogTitle.setText(R.string.delete_diary);
	}

	@Override
	public void onClick(View v) {
		if (v == cancelButton) {
			this.dismiss();
		}

	}

}
